#include "util.hpp"
#include <string>
#include <cstring>
#include <vector>
#include <functional>

using namespace std;
using namespace Util;

using func_t = std::function<void()>;

void show()
{
    cout << "正在处理其他任务" << endl;
}

int main()
{
    vector<func_t> funcs;  //
    funcs.push_back(show);

    //将标准输入流由阻塞改为非阻塞
    SetNonBlock(0);

    char buffer[1024];
    while(true)
    {
        buffer[0] = 0;
        int n = scanf("%s", buffer);
        if(n == -1)
        {
            cout << "error: " << errno << " desc: " << strerror(errno) << endl; 
            for(const auto &f : funcs)
            {
                f();
            }
        }
        else
        {
            cout << "刚刚获取的信息是： " << buffer << " n:" << n << endl;
        }

        sleep(1);
    }


    return 0;
}

